package com.gzj.springboot.service;

import com.gzj.springboot.domain.User;
import com.gzj.springboot.mapper.UserMapper;
import com.gzj.springboot.tools.Data_Processing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Userservice {

    /**
     * 注入dao
     */
    @Autowired(required = true)
    private UserMapper userMapper;
    //用户登录
    public User login(String user_name, String password){

        return userMapper.login(user_name,password);
    }
    //用户注册
    public int adduser(String user_name,String password,Integer age,String addr,String name){
        /**
         * 看Mapper中的注释
         */
//        //Data_Processing data_processing = new Data_Processing();
//       //id =data_processing.RandomCharacters();
        return userMapper.adduser1(user_name,password,age,addr,name);
    }
    //用户注册 用自己的id
    public int adduer2(String id,String user_name,String password,Integer age,String addr,String name){

        return userMapper.adduser2(id,user_name,password,age,addr,name);
    }
    //按user_name查找用户
    public User queryUserById(String user_name){
        return userMapper.queryUserById(user_name);
    }

    //按user_name更改用户数据
    public int updateId(String name,Integer age,String addr,String user_name){
        return userMapper.updateId(name,age,addr,user_name);
    }
    //按user_name修改用户密码
    public int updatePwd(String password,String user_name){
        return userMapper.updatePwd(password,user_name);
    }

    public int updatePhoto(String file,String user_name){ return userMapper.updatePhoto(file,user_name);}

}
